<?php

/**
 * Html table item
 *
 * @author dll_hell_2
 */
class table {
    
    /**
     *
     * @var array Array of rows in html table
     */
    protected $rows = array();
    /**
     *
     * @param array $headers Array of headers for hmtl table
     */
    public function __construct($headers) {
        
        array_push($this->rows, $headers);        
    }
    /**
     *Adds $content as a row to html table.
     * @param array $content
     */
    public function addRow($content)
    {
        
            array_push($this->rows, $content);
    }
    /**
     *Prints html table.
     * @return html table
     */
    public function __toString()
    {
        $result = '<table>';
        foreach($this->rows as $row)
        {
            $result .= '<tr>';
            foreach($row as $row_item)
            {                
                $result = sprintf("<td>%s</td>",
                        $row_item);
            }
            $result .= '</tr>';
        }
        
        $result .= '</table>';
        return $result;
    }
}

?>
